package com.xinqi.xinqidev.publisher.consumer.listeners;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author xin麒
 * @date 2023/11/20 22:58
 */
@Slf4j
@Component
public class TopicMQListener {


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "xinqiyayaTopic.queue1", durable = "true"),
            exchange = @Exchange(name = "xinqiyaya.topic", type = ExchangeTypes.TOPIC),
            key = "china.#"
    ))
    public void listenerTopicQueue1(String msg) {
        log.debug("Topic消费者1监听到【xinqiyayaTopic.queue1】队列的消息是"+msg);
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "xinqiyayaTopic.queue2", durable = "true"),
            exchange = @Exchange(name = "xinqiyaya.topic", type = ExchangeTypes.TOPIC),
            key = "#.news"
    ))
    public void listenerTopicQueue2(String msg) {
        log.debug("Topic消费者2监听到【xinqiyayaTopic.queue2】队列的消息是"+msg);
    }





}
